from django.contrib import admin

# Register your models here.

from .models import Users, Role, Api,SimpleOperationLog


# 设置header
admin.site.site_header = "管理后台系统"
# 设置title
admin.site.site_title = "管理后台系统"


class UsersAdmin(admin.ModelAdmin):
    # 设置列表可显示的字段
    list_display = [
        "id",
        "username",
        "email",
        "mobile",
        "name",
        "gender",
        "status",
    ]
    # 按更新日期排序
    ordering = ("id",)
    # 每页显示条目数
    list_per_page = 10


class RoleAdmin(admin.ModelAdmin):
    list_display = ["id", "name", "status", "code"]
    # 按更新日期排序
    ordering = ("id",)
    # 每页显示条目数
    list_per_page = 10


class ApiAdmin(admin.ModelAdmin):
    list_display = ["id", "path", "desc", "api_group", "method"]
    # 按更新日期排序
    ordering = ("id",)
    # 每页显示条目数
    list_per_page = 10
    

class SimpleOperationLogAdmin(admin.ModelAdmin):
    list_display = ['user_id', 'object_cls', 'method', 'ip', 'remark','create_time']
    # 按更新日期排序
    ordering = ("id",)
    # 每页显示条目数
    list_per_page = 10

admin.site.register(Users, UsersAdmin)
admin.site.register(Role, RoleAdmin)
admin.site.register(Api, ApiAdmin)
admin.site.register(SimpleOperationLog,SimpleOperationLogAdmin)
